import request from "@/utils/request";
import { praseStrEmpty } from "@/utils/ruoyi";

// 查询用户列表
export function listUser(query) {
  return request({
    url: "/system/user/list",
    method: "get",
    params: query,
  });
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: "/system/user/" + praseStrEmpty(userId),
    method: "get",
  });
}

// 新增用户
export function addUser(data) {
  return request({
    url: "/system/user",
    method: "post",
    data: data,
  });
}

// 修改用户
export function updateUser(data) {
  return request({
    url: "/system/user",
    method: "put",
    data: data,
  });
}

// 删除用户
export function delUser(userId) {
  return request({
    url: "/system/user/" + userId,
    method: "delete",
  });
}

// 导出用户
export function exportUser(query) {
  return request({
    url: "/system/user/export",
    method: "get",
    params: query,
  });
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password,
  };
  return request({
    url: "/system/user/resetPwd",
    method: "put",
    data: data,
  });
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status,
  };
  return request({
    url: "/system/user/changeStatus",
    method: "put",
    data: data,
  });
}

// 用户状态修改
export function changeAgentFlag(userId, agentFlag) {
  const data = {
    userId,
    agentFlag,
  };
  return request({
    url: "/system/user/changeAgentFlag",
    method: "put",
    data: data,
  });
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: "/system/user/profile",
    method: "get",
  });
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: "/system/user/profile",
    method: "put",
    data: data,
  });
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword,
  };
  return request({
    url: "/system/user/profile/updatePwd",
    method: "put",
    params: data,
  });
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: "/system/user/profile/avatar",
    method: "post",
    data: data,
  });
}

// 下载用户导入模板
export function importTemplate() {
  return request({
    url: "/system/user/importTemplate",
    method: "get",
  });
}
// agentChange 改变代理的集团
export function agentChangeGroup(data) {
  return request({
    url: "/system/agent/addSysAgent",
    method: "post",
    data: data,
  });
}

// 用户密码重置
export function getLeftData(data) {
  return request({
    url: "/system/dept/selectSysAgentList",
    method: "get",
    params: data,
  });
}

//
export function getRightData(data) {
  return request({
    url: "/system/agent/sysAgentlist",
    method: "get",
    params: data,
  });
}

// GET /system/user/listCooperator 获取合伙人列表
export function listCooperator(data) {
  return request({
    url: "/system/user/listCooperator",
    method: "get",
    params: data,
  });
}

// GET /system/user/getFirstAccount 获取归属一级账号
export function getFirstAccount(data) {
  return request({
    url: "/system/user/getFirstAccount",
    method: "get",
    params: data,
  });
}
export function getLevelApi(data) {
  return request({
    url: "/system/user/getLevel",
    method: "get",
    params: data,
  });
}
// 获取权限对应的油企列表
export function getEnterpriseListApi(data) {
  return request({
    url: "/enterprise/info/getEnterpriseList",
    method: "get",
    params: data,
  });
}

// /system/user/SysUserGetInfo
export function sysUserGetInfo(data) {
  return request({
    url: "/system/user/SysUserGetInfo",
    method: "get",
    params: data,
  });
}

//get /system/role/list 角色列表
export function roleList(data) {
  return request({
    url: "/system/role/list",
    method: "get",
    params: data,
  });
}

//get /system/role/listForAdmin 用户管理页面获取角色列表选择下拉框
export function listForAdmin(data) {
  return request({
    url: "/system/role/listForAdmin",
    method: "get",
    params: data,
  });
}

//get /system/user/getStationStaffRoleByUser 用户管理页面获取角色列表选择下拉框  员工
export function getStationStaffRoleByUser(data) {
  return request({
    url: "/system/user/getStationStaffRoleByUser",
    method: "get",
    params: data,
  });
}

// /system/user/getRoleByUser  可分配角色 get
export function getRoleByUser(data) {
  return request({
    url: "/system/user/getRoleByUser",
    method: "get",
    params: data,
  });
}
// 获取角色分配和角色
export function getInfoNewApi(userId) {
  return request({
    url: `/system/user/getInfoNew/${userId}`,
    method: "get",
  });
}
